/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseHandlePersonAdjustInfoPageRequest;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.HandleAdjustCaseInfoPageRequest;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.HandlePersonAdjustInfoAddDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.HandlePersonAdjustInfoDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseHandlePersonAdjustInfoService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseHandlePersonAjustInfoDetailVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseHandlePersonAjustInfoVo;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.HandleAdjustCaseInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述: 案件承办人调整明细表 case_handle_person_adjust_info 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年10月14日
 */
@RestController
@RequestMapping("/punish/ucase/caseHandlePersonAdjustInfo")
public class CaseHandlePersonAdjustInfoController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseHandlePersonAdjustInfoController.class);

    @Autowired
    private ICaseHandlePersonAdjustInfoService caseHandlePersonAdjustInfoService;
    /**
     *  案件列表
     * @author liyafeng
     * @date 2022/10/14
     * @param request
     * @return {@link Result< PageResponse< CaseHandlePersonAjustInfoVo>>}
     */
    @PostMapping("/getHandleAdjustCaseInfoPageList")
    public Result<PageResponse<HandleAdjustCaseInfoVo>> getCaseInfoPageList(@RequestBody @Validated HandleAdjustCaseInfoPageRequest request) {
        List<HandleAdjustCaseInfoVo> pageList = caseHandlePersonAdjustInfoService.getHandleAdjustCaseInfoPageList(request);
        return Result.success(new PageResponse<>(pageList));
    }
    /**
     * 调整记录列表
     * @author liyafeng
     * @date 2022/10/14
      * @param request
     * @return {@link Result< PageResponse< CaseHandlePersonAjustInfoVo>>}
     */
    @PostMapping("/getCaseHandlePersonAdjustInfoPageList")
    public Result<PageResponse<CaseHandlePersonAjustInfoVo>> getCaseHandlePersonAdjustInfoPageList(@RequestBody @Validated CaseHandlePersonAdjustInfoPageRequest request) {
        List<CaseHandlePersonAjustInfoVo> pageList = caseHandlePersonAdjustInfoService.getCaseHandlePersonAdjustInfoPageList(request);
        return Result.success(new PageResponse<>(pageList));
    }
    /**
     * 调整明细
     * @author liyafeng
     * @date 2022/10/18
      * @param dto
     * @return {@link Result< CaseHandlePersonAjustInfoDetailVo>}
     */
    @PostMapping("/getCaseHandlePersonAdjustInfoDetail")
    public Result<CaseHandlePersonAjustInfoDetailVo> getCaseHandlePersonAdjustInfoDetail(@RequestBody @Validated HandlePersonAdjustInfoDto dto) {
        CaseHandlePersonAjustInfoDetailVo vo = caseHandlePersonAdjustInfoService.getCaseHandlePersonAdjustInfoDetail(dto);
        return Result.success(vo);
    }

    /**
     * 调整承办人员
     * @author liyafeng
     * @date 2022/10/18
      * @param dto
     * @return {@link Result< String>}
     */
    @PostMapping("/addCaseHandlePersonAdjustInfo")
    public Result<String> addCaseHandlePersonAdjustInfo(@RequestBody @Validated HandlePersonAdjustInfoAddDto dto) {
        int num = caseHandlePersonAdjustInfoService.addCaseHandlePersonAdjustInfo(dto);
        if(num>0){
            return Result.success("调整成功");
        }
        return Result.error("调整失败");
    }
    /**
     * 校验是否有文书在审批中
     * @author liyafeng
     * @date 2022/10/24
      * @param dto
     * @return {@link Result< String>}
     */
    @PostMapping("/checkIsExistDocumentIsApproval")
    public Result<String> checkIsExistDocumentIsApproval(@RequestBody @Validated HandlePersonAdjustInfoDto dto) {

        int num = caseHandlePersonAdjustInfoService.checkIsExistDocumentIsApproval(dto);
        if(num>0){
            return Result.error("当前案件有审批中的文书，请先完成审批，再调整当事人");
        }
        return Result.success("校验成功");
    }





}